home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
gnulib2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-22
|
31KB
|
1,669 lines
/* WARNING: compile this in 32 bit int mode even for short library */
#include <string.h>
#include <memory.h>
#ifndef _COMPILER_H
#include <compiler.h>
#endif
#ifdef __DEF_ALL__ /* this def'ed when making on the ST */
#define L_adddi3
#define L_subdi3
#define L_muldi3
#define L_divdi3
#define L_moddi3
#define L_udivdi3
#define L_umoddi3
#define L_negdi2
#define L_anddi3
#define L_iordi3
#define L_xordi3
#define L_lshrdi3
#define L_lshldi3
#define L_ashldi3
#define L_ashrdi3
#define L_one_cmpldi2
#define L_bdiv
#define L_cmpdi2
#define L_ucmpdi2
#define L_fixunsdfdi
#define L_fixdfdi
#define L_floatdidf
/* gcc-2.0 stuff */
#if 0 /* NOTE: these are now covered, and should not be generated here */
#define L_lshrsi3
#define L_lshlsi3
#define L_ashrsi3
#define L_ashlsi3
#define L_eqdf2
#define L_nedf2
#define L_gtdf2
#define L_gedf2
#define L_ltdf2
#define L_ledf2
#define L_fixsfsi
#define L_floatsisf
#define L_eqsf2
#define L_nesf2
#define L_gtsf2
#define L_gesf2
#define L_ltsf2
#define L_lesf2
#endif
#define L_fxussfsi
#define L_gccbcmp
#endif /* __DEF_ALL__ */
/* More subroutines needed by GCC output code on some machines. */
/* Compile this one with gcc. */
#if 0
#include "config.h" /* dont drag this in, just define relevant
stuff from xm/tm-atari.h & xm/tm-m68k.h here */
#else
/* #defines that need visibility everywhere. */
#define FALSE 0
#define TRUE 1
/* This describes the machine the compiler is hosted on. */
#define HOST_BITS_PER_CHAR 8
#define HOST_BITS_PER_SHORT 16
#define HOST_BITS_PER_INT 32
#define HOST_BITS_PER_LONG 32
/* Define this if most significant bit is lowest numbered
in instructions that operate on numbered bit-fields.
This is true for 68020 insns such as bfins and bfexts.
We make it true always by avoiding using the single-bit insns
except in special cases with constant bit numbers. */
#define BITS_BIG_ENDIAN
/* Define this if most significant byte of a word is the lowest numbered. */
/* That is true on the 68000. */
#define BYTES_BIG_ENDIAN
/* Define this if most significant word of a multiword number is numbered. */
/* For 68000 we can decide arbitrarily
since there are no machine instructions for them. */
#define WORDS_BIG_ENDIAN
/* number of bits in an addressible storage unit */
#define BITS_PER_UNIT 8
/* Width in bits of a "word", which is the contents of a machine register.
Note that this is not necessarily the width of data type `int';
if using 16-bit ints on a 68000, this would still be 32.
But on a machine with 16-bit registers, this would be 16. */
#define BITS_PER_WORD 32
/* Width of a word, in units (bytes). */
#define UNITS_PER_WORD 4
/* Width in bits of a pointer.
See also the macro `Pmode' defined below. */
#define POINTER_SIZE 32
/* Allocation boundary (in *bits*) for storing pointers in memory. */
#define POINTER_BOUNDARY 16
/* Allocation boundary (in *bits*) for storing arguments in argument list. */
#define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32)
/* Boundary (in *bits*) on which stack pointer should be aligned. */
#define STACK_BOUNDARY 16
/* Allocation boundary (in *bits*) for the code of a function. */
#define FUNCTION_BOUNDARY 16
/* Alignment of field after `int : 0' in a structure. */
#define EMPTY_FIELD_BOUNDARY 16
/* No data type wants to be aligned rounder than this. */
#define BIGGEST_ALIGNMENT 16
/* Define this if move instructions will actually fail to work
when given unaligned data. */
#define STRICT_ALIGNMENT
/* Define number of bits in most basic integer type.
(If undefined, default is BITS_PER_WORD). */
#ifdef __MSHORT__
#define INT_TYPE_SIZE 16
#else
#define INT_TYPE_SIZE 32
#endif
#endif
#ifndef minix
#include <stddef.h>
#else
typedef unsigned long size_t;
#include "lib.h"
#endif
#ifndef SItype
#define SItype long int
#endif
/* long long ints are pairs of long ints in the order determined by
WORDS_BIG_ENDIAN. */
#ifdef WORDS_BIG_ENDIAN
struct longlong {long high, low;};
#else
struct longlong {long low, high;};
#endif
/* We need this union to unpack/pack longlongs, since we don't have
any arithmetic yet. Incoming long long parameters are stored
into the `ll' field, and the unpacked result is read from the struct
longlong. */
typedef union
{
struct longlong s;
long long ll;
SItype i[2];
unsigned SItype ui[2];
} long_long;
/* Internally, long long ints are strings of unsigned shorts in the
order determined by BYTES_BIG_ENDIAN. */
#define B 0x10000
#define low16 (B - 1)
#ifdef BYTES_BIG_ENDIAN
/* Note that HIGH and LOW do not describe the order
of words in a long long. They describe the order of words
in vectors ordered according to the byte order. */
#define HIGH 0
#define LOW 1
#define big_end(n) 0
#define little_end(n) ((n) - 1)
#define next_msd(i) ((i) - 1)
#define next_lsd(i) ((i) + 1)
#define is_not_msd(i,n) ((i) >= 0)
#define is_not_lsd(i,n) ((i) < (n))
#else
#define LOW 0
#define HIGH 1
#define big_end(n) ((n) - 1)
#define little_end(n) 0
#define next_msd(i) ((i) + 1)
#define next_lsd(i) ((i) - 1)
#define is_not_msd(i,n) ((i) < (n))
#define is_not_lsd(i,n) ((i) >= 0)
#endif
/* These algorithms are all straight out of Knuth, vol. 2, sec. 4.3.1. */
__EXTERN long long __adddi3 __PROTO((long long u, long long v));
__EXTERN long long __anddi3 __PROTO((long long u, long long v));
__EXTERN long long __iordi3 __PROTO((long long u, long long v));
__EXTERN long long __xordi3 __PROTO((long long u, long long v));
__EXTERN long long __one_cmpldi2 __PROTO((long long u));
__EXTERN long long __lshldi3 __PROTO((long long u, long int b1));
__EXTERN long long __lshrdi3 __PROTO((long long u, long int b1));
__EXTERN long long __ashldi3 __PROTO((long long u, long int b1));
__EXTERN long long __ashrdi3 __PROTO((long long u, long int b1));
__EXTERN long long __subdi3 __PROTO((long long u, long long v));
__EXTERN long long __muldi3 __PROTO((long long u, long long v));
__EXTERN long long __divdi3 __PROTO((long long u, long long v));
__EXTERN long long __moddi3 __PROTO((long long u, long long v));
__EXTERN long long __udivdi3 __PROTO((long long u, long long v));
__EXTERN long long __umoddi3 __PROTO((long long u, long long v));
__EXTERN long long __negdi2 __PROTO((long long u));
__EXTERN void __bdiv __PROTO((unsigned short *a, unsigned short *b, unsigned short *q, unsigned short *r, size_t m, size_t n));
__EXTERN SItype __cmpdi2 __PROTO((long long a, long long b));
__EXTERN SItype __ucmpdi2 __PROTO((long long a, long long b));
__EXTERN long long __fixunsdfdi __PROTO((double a));
__EXTERN long long __fixdfdi __PROTO((double a));
__EXTERN double __floatdidf __PROTO((long long u));
__EXTERN int __builtin_saveregs __PROTO((void));
__EXTERN unsigned SItype __fixunssfsi __PROTO((float a));
#ifdef L_adddi3
static int badd __PROTO((unsigned short *a, unsigned short *b, unsigned short *c, size_t n));
long long
__adddi3 (u, v)
long long u, v;
{
long a[2], b[2], c[2];
long_long w;
long_long uu, vv;
uu.ll = u;
vv.ll = v;
a[HIGH] = uu.s.high;
a[LOW] = uu.s.low;
b[HIGH] = vv.s.high;
b[LOW] = vv.s.low;
badd ((unsigned short *)a, (unsigned short *)b, (unsigned short *)c, sizeof c);
w.s.high = c[HIGH];
w.s.low = c[LOW];
return w.ll;
}
static int
badd (a, b, c, n)
unsigned short *a, *b, *c;
size_t n;
{
unsigned long acc;
int i;
n /= sizeof *c;
acc = 0;
for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
{
/* Widen before adding to avoid loss of high bits. */
acc += (unsigned long) a[i] + b[i];
c[i] = acc & low16;
acc = acc >> 16;
}
return acc;
}
#endif
#ifdef L_anddi3
long long
__anddi3 (u, v)
long long u, v;
{
long_long w;
long_long uu, vv;
uu.ll = u;
vv.ll = v;
w.s.high = uu.s.high & vv.s.high;
w.s.low = uu.s.low & vv.s.low;
return w.ll;
}
#endif
#ifdef L_iordi3
long long
__iordi3 (u, v)
long long u, v;
{
long_long w;
long_long uu, vv;
uu.ll = u;
vv.ll = v;
w.s.high = uu.s.high | vv.s.high;
w.s.low = uu.s.low | vv.s.low;
return w.ll;
}
#endif
#ifdef L_xordi3
long long
__xordi3 (u, v)
long long u, v;
{
long_long w;